package io.jmqtt.handler;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.hutool.json.JSONUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;
import io.netty.handler.codec.mqtt.MqttMessage;

/**
 * mqtt 消息处理类
 * 
 * @author chenhua
 *
 */
public class MqttMessageHandler extends MessageToMessageEncoder<MqttMessage> {

	private static final Logger LOG = LoggerFactory.getLogger(MqttMessageHandler.class);

	@Override
	protected void encode(ChannelHandlerContext ctx, MqttMessage msg, List<Object> out) throws Exception {
		LOG.info(JSONUtil.toJsonStr(msg));
	}

}
